<template>
    <div class="cmdcfg" style="margin-top:5px">
        <exSelect v-model="type" :dictList="typeList" size="mini" elstyle="width:100px;min-width:100px"></exSelect>
                
        <span v-if="runtime">执行次数: {{runtime}}</span>
    </div>
</template>


<script>

export default {
    components:{
    },
    props: {
        cmdInfo: { type: Object, default: {} },
        devInfo:{ type: Object, default: {} },
        cmdIdx : {},
    },
    data() {
        return {
            level : this.cmdInfo.level || 0,
            timer : null,
            runtime : 0 ,
            type : this.cmdInfo.logicType || "",
            typeList:[
                {name:"continue",value:"continue"},
                {name:"break",value:"break"},
                {name:"return",value:"return"}
            ],
        };
    },
    inject: ['doDevCmd','doNextCmd'],
     

    mounted() {
    },

    methods: {
        saveCmd(){
            this.cmdInfo.logicType = this.type;
        },
        initCmd(){
            this.runtime=0;
        },
        preCheck(){
            return true;
        },
        runCmd(isOnce){
            if(!this.preCheck()){
                this.$emit("stopRun")
                return;
            }
            this.runtime++;
            this.$emit("stopRun")
            var param ={};
            param[this.type] = true;
            if(isOnce!==true) this.doNextCmd(param);
        },
        stopCmd(){
            this.$emit("stopRun")
        },
        
    }
}
</script>

<style lang="less" scoped>
    .cmdcfg{
        display: inline-block;
    }
</style>
